﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Net;
using System.IO;

namespace wljHomoWork2WS
{
    public class wljWS2:AwljWS
    {
        //定义URL
        private string _uri;
        public  string Uri
        {
            get
            {
                return this._uri;
            }
            set
            {
                this._uri = value;
            }
        }
        public override XmlDocument _XmlDoc
        {
            get
            {
                try
                {
                    //根据指定的URL模拟一个网络请求
                    HttpWebRequest wrqPage = HttpWebRequest.Create(Uri) as HttpWebRequest;
                    //设定UserAgent的属性
                    wrqPage.UserAgent = "Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1)";
                    //获取网络相应
                    WebResponse wrsPage = wrqPage.GetResponse();
                    //获取相应数据流
                    Stream strmPage = wrsPage.GetResponseStream();
                    //根据数据流创建XmlReader对象
                    XmlReader _XmlReader = XmlReader.Create(strmPage);
                    //创建XmlDoc对象
                    XmlDocument _Doc = new XmlDocument();
                    _Doc.Load(_XmlReader);
                    return _Doc;
                }
                catch (Exception Ex)
                {
                    throw new Exception(Ex.Message);
                }
            }
        }
    }
}
